<%@ page contentType="text/html;charset=UTF-8"%>
<%@include file="module/common.jsp"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="cosmo云工厂">
<meta name="Keywords" content="cosmo,cosmo云工厂">
<title>cosmo云工厂</title>
<link href="${ctxStatic}/cloudfactory/css/basic.css" rel="stylesheet"
	type="text/css" />
<link href="${ctxStatic}/cloudfactory/css/main.css" rel="stylesheet"
	type="text/css" />
<link href="${ctxStatic}/cloudfactory/css/flex.css" rel="stylesheet"
	type="text/css" />
<link href="${ctxStatic}/cloudfactory/css/cloudFoundry.css"
	rel="stylesheet" type="text/css" />
<!–[if lt IE9]>
<script src="${ctxStatic}/cloudfactory/js/html5.js"></script>
<![endif]–>
</head>

<body>
	<div class="sys_warp">
		<!--header开始-->
		<jsp:include page="module/head.jsp" flush="true" />
		<div class="banner child_banner title sys_wrap"></div>
		<!--header结束,banner开始-->
		<div class="background">
			<div class="titleTextBackground absolute-left-center-top-self-center">
				<img class="titleTextBackgroundImg1"
					src="${ctxStatic}/cloudfactory/img/shoppingCart/titleTextBackground.png"
					alt=""> <img
					class="titleTextBackgroundImg2 absolute-self-center"
					src="${ctxStatic}/cloudfactory/img/shoppingCart/gouWuChe.png"
					alt="">
				<p class="titleText1 absolute-self-top-center">
					SHOPPING<span>&ensp;CART</span>
				</p>
				<p class="titleText2 absolute-self-top-center">购物车</p>
				<img class="titleTextLine"
					src="${ctxStatic}/cloudfactory/img/shoppingCart/line.png" alt="">
				<div class="rightMenu absolute-self-center">
					<div class="gouWuChe2">
						<img
							src="${ctxStatic}/cloudfactory/img/shoppingCart/gouWuChe2.png"
							alt="">
					</div>
					<div class="customer">
						<p>客服</p>
					</div>
					<div class="help">
						<p>帮助</p>
					</div>
				</div>
			</div>

			<div class="tableAllBox pb_40">
				<table id="tableTitle">
					<tr>
						<th class="tableTitle1">功能</th>
						<th class="tableTitle2">功能类别</th>
						<th class="tableTitle3">功能名称</th>
						<th class="tableTitle4">所属模块</th>
						<th class="tableTitle5">购买时长</th>
						<th class="tableTitle6">对应工厂</th>
						<th class="tableTitle7">价格</th>
						<th class="tableTitle8">操作</th>
					</tr>
				</table>

				<div id="tableBox">
					<div class="tableOrderBox">
						<div class="tableproductBox">
							<div class="borderLine absolute-left-center"></div>
							<table class="tableproduct" id="contentTable" name="contentTable">
								<c:forEach items="${order}" var="o">
									<tr class="tableproductTr">
									
										<td class="tableproduct1">${o.menuName }</td>
										<td class="tableproduct2"><c:choose>
												<c:when test="${o.isRequired ==0}">
基础功能
</c:when>

												<c:otherwise>
							选配功能
							</c:otherwise>
											</c:choose></td>
										<td class="tableproduct3">${o.functionName }</td>
										<td class="tableproduct3">${fns:getDictLabel(o.menuType, 'function_type', '')}</td>
										<td class="tableproduct5">
										
										 <select name="duration" id="duration" value="${o.useTime }" 
										 onchange="changeMonth(this.options[this.options.selectedIndex].value,'${o.id }')">
                                            <c:if test="${o.useTime==1 }">
                                            <option value="1" selected="selected">一个月</option>
                                            <option value="6">六个月</option>
                                            <option value="12">十二个月</option>
                                            
                                            </c:if>
                                             <c:if test="${o.useTime==6 }">
                                              <option value="1">一个月</option>
                                            <option value="6"  selected="selected">六个月</option>
                                            <option value="12">十二个月</option>
                                             </c:if>
                                              <c:if test="${o.useTime==12 }">
                                               <option value="1">一个月</option>
                                            <option value="6" >六个月</option>
                                            <option value="12" selected="selected">十二个月</option>
                                              
                                              </c:if>
                                            
                                            
                                        </select>
										
										
										</td>
										<td class="tableproduct6">${o.plant }</td>
										<td class="tableproduct7">${o.functionMoney }元</td>
										<td class="tableproduct8"><input value="删除"
											onclick="deleOrder('${o.id }')" type="button"></td>
									</tr>


								</c:forEach>

							</table>
						</div>


					</div>


				</div>

				<div class="shoppingCartPrice">
					<p class="allPrice">
						总价：<span>￥${money }元</span>
					</p>
					<!-- <a href="shoppingList.html"> -->
					<c:if test="${orderStatus=='3' }">
					<div class="putOrder">
						<img class="absolute-self-center"
							src="${ctxStatic}/cloudfactory/img/shoppingCart/put.png" alt="">
						<p onclick="submitOrder('${orderNo }')">提交订单</p>
					</div>
					</c:if>
					<div class="putOrder">
						<img class="absolute-self-center"
							src="${ctxStatic}/cloudfactory/img/shoppingCart/put.png" alt="">
						<p onclick="goOn('${orderNo }')">继续购物</p>
					</div>
					<!-- </a> -->
				</div>

			</div>
			<!--主体结束,footer开始-->
			<jsp:include page="module/foot.jsp" flush="true" />
			<!--footer结束-->
		</div>
</body>
<script type="text/javascript"
	src="${ctxStatic}/cloudfactory/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript"
	src="${ctxStatic}/cloudfactory/js/main.js"></script>
<script>


function changeMonth(value,id) {
	var orderNo = "${orderNo}";
window.location.href="${ctx}/order/changeMonth?orderNo="+orderNo+"&id="+id+"&value="+value;
}




	function goOn(orderNo) {
	window.location.href="${ctx}/order/goCloudMarket?num=${num}&orderNo="+orderNo;
	}
	
	function submitOrder(orderNo) {
		 $.ajax({
				//几个参数需要注意一下
				type : "POST",//方法类型
				dataType : "json",//预期服务器返回的数据类型
				url : "${ctx}/order/submitOrder",//url
				data : {
					
					orderNo:orderNo
				},
				success : function(result) {
					alert("提交成功");
					window.location.href="${ctx}/order/goOrderList";
				}
			});
	}
	function deleOrder(id) {
		var orderNo = "${orderNo}";
		window.location.href="${ctx}/order/deleOrder?id="+id+"&orderNo="+orderNo;
	}

	$(document).ready(function() {
		uniteTable();
	});

	/////////////////////////////////////////////// 
	//功能：合并表格 
	//参数：tb－需要合并的表格ID 
	//参数：colLength－－需要对前几列进行合并，比如， 
	//想合并前两列，后面的数据列忽略合并，colLength应为2 
	//缺省表示对全部列合并 
	//data:2011.11.06 
	/////////////////////////////////////////////// 
	function uniteTable() {
		var colLength = 2;
		var tb = document.getElementById("contentTable");
		//检查表格是否规整 
		if (!checkTable(tb))
			return;
		var i = 0;
		var j = 0;
		var rowCount = tb.rows.length; //行数 
		var colCount = tb.rows[0].cells.length; //列数 
		var obj1 = null;
		var obj2 = null;
		//为每个单元格命名 
		for (i = 0; i < rowCount; i++) {
			for (j = 0; j < colCount; j++) {
				tb.rows[i].cells[j].id = "tb__" + i.toString() + "_"
						+ j.toString();
			}
		}
		//逐列检查合并 
		for (i = 0; i < colCount; i++) {
			if (i == colLength)
				return;
			obj1 = document.getElementById("tb__0_" + i.toString())
			for (j = 1; j < rowCount; j++) {
				obj2 = document.getElementById("tb__" + j.toString() + "_"
						+ i.toString());
				if (obj1.innerText == obj2.innerText) {
					obj1.rowSpan++;
					obj2.parentNode.removeChild(obj2);
				} else {
					obj1 = document.getElementById("tb__" + j.toString() + "_"
							+ i.toString());
				}
			}
		}
	}

	///////////////////////////////////////// 
	//功能：检查表格是否规整 
	//参数：tb－－需要检查的表格ID 
	//data: 2011.11.06
	///////////////////////////////////////// 
	function checkTable(tb) {
		if (tb.rows.length == 0)
			return false;
		if (tb.rows[0].cells.length == 0)
			return false;
		for (var i = 0; i < tb.rows.length; i++) {
			if (tb.rows[0].cells.length != tb.rows[i].cells.length)
				return false;
		}
		return true;
	}
</script>
</html>